﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Miner.Model.Logic.Enums;
using Miner.UI.Controls.Interfaces;

namespace Miner.UI.Controls
{
    public partial class GameInfoCtrl : UserControl, IGameInfoCtrl
    {
        public GameInfoCtrl()
        {
            InitializeComponent();
        }

        private void GameInfoCtrl_SizeChanged(object sender, EventArgs e)
        {
            this.btnRestart.Location = new Point(this.Width/2 - this.btnRestart.Width/2, this.Height/2 - this.btnRestart.Height/2);
            this.lblMinesLeft.Width = this.btnRestart.Left;
            this.lblTimeElapsed.Location = new Point(this.btnRestart.Right, this.lblTimeElapsed.Top);
            this.lblTimeElapsed.Width = this.Right - this.lblTimeElapsed.Left;
        }

        public string MinesLeftValue
        {
            get
            {
                return lblMinesLeft.Text;
            }
            set
            {
                lblMinesLeft.Text = value;
            }
        }

        public string TimeElapsedValue
        {
            get
            {
                return lblTimeElapsed.Text;
            }
            set
            {
                lblTimeElapsed.Text = value;
            }
        }


        public void ChangeSmile(SmileChangeReason reason)
        {
            switch (reason)
            {
                case SmileChangeReason.Fail:
                    btnRestart.ImageKey = "FailSmile.bmp";
                    break;
                case SmileChangeReason.Pause:
                    btnRestart.ImageKey = "PauseSmile.bmp";
                    break;
                case SmileChangeReason.Resume:
                case SmileChangeReason.Victory:
                    btnRestart.ImageKey = "OkSmile.bmp";
                    break;
            }
        }


        public event EventHandler PauseClick;

        private void btnRestart_Click(object sender, EventArgs e)
        {
            if(this.PauseClick!=null)
            {
                this.PauseClick(sender, e);
            }
        }
    }
}
